public class LogIn {
    private String userName = "zxcvbnm";
    private String password = "123456";

    public void loginInfo(String userName, String password)throws UserNameException,PasswordException{
        if(!this.userName.equals(userName)){
            throw new UserNameException("用户名有误");
        }
        if(!this.password.equals(password)){
            throw new PasswordException("密码有误");
        }
        System.out.println("登录成功");
    }
    public static void main(String[] args) {
        LogIn login = new LogIn();
        try{
            login.loginInfo("zxcvbnmj", "123456");
        }catch(UserNameException e){
            e.printStackTrace();
            System.out.println("UserNameException");

        }catch(PasswordException e){
            e.printStackTrace();
            System.out.println("PasswordException");
        }
    }
}
